package com.kaikeba.estack.web;

import com.kaikeba.estack.bean.User;
import com.kaikeba.estack.web.constant.WebConstant;

/**
 * @Auth xingwan
 * @Date 2020/9/26 22:27
 **/
public class SecurityFacade {

    /**
     * 获取当前登录的用户
     *
     * @return
     */
    public static User getCurrentUser() {
        return ApplicationContext.getObjectBySession(WebConstant.LOGIN_USER_KEY);
    }

    /**
     * 设置当前登录的用户
     *
     * @param user
     */
    public static void setCurrentUser(User user) {
        ApplicationContext.putObject2Session(WebConstant.LOGIN_USER_KEY, user);
    }

    /**
     * 退出
     */
    public static void logout() {
        ApplicationContext.clearSession();
    }
}
